<?php
declare (strict_types=1);

use think\facade\Route;

/**
 * 套卷练习
 */
Route::group('admin/module/<module_id>/rollup', function () {
    // 套卷
    Route::get('config', 'config');
    // 新建套卷
    Route::rule('create', 'create', 'GET|POST');
    // 专套卷操作
    Route::group('<rollup_id>', function () {
        // 编辑套卷
        Route::rule('edit$', 'edit', 'GET|PUT');
        // 编辑专项某个字段
        Route::put('edit/<field>', 'editField')->pattern(['field' => '[a-zA-Z_]+']);
        // 删除
        Route::delete('delete', 'delete');
    })->pattern(['rollup_id' => '\d+']);
})->prefix('\app\exam\service\admin\ModuleRollup@')
    ->middleware('adminRoute')
    ->pattern(['module_id' => '\d+']);

/**
 * 套卷试卷管理
 */
Route::group('admin/module/<module_id>/rollup/<rollup_id>/paper', function () {
    Route::get('$', 'paperList');
    // 试卷选择面板
    Route::get('choose/options', 'getChooseOptions');
    // 获取试卷列表
    Route::get('choose/list', 'getChooseList');
    // 新建试卷
    Route::post('create', 'create');
    // 移除试卷
    Route::delete('<id>/delete', 'delete')->pattern(['id' => '\d+']); // 删除
    // 批量移除
    Route::delete('deletes/<ids>', 'deletes')->pattern(['ids' => '[\d,]+']);// 批量删除
})->prefix('\app\exam\service\admin\ModuleRollupPaper@')
    ->middleware('adminRoute')
    ->pattern(['module_id' => '\d+', 'rollup_id' => '\d+']);

/** 套卷练习订单 */
Route::group('admin/rollup/order', function () {
    // 订单列表
    Route::get('$', 'orderList');
    // 订单导出
    Route::post('export', 'export');
})->prefix('\app\exam\service\admin\Order@')
    ->middleware('adminRoute')
    ->append(['product_key' => 'rollup']);